package cn.ztuo.bitrade.dao;

import cn.ztuo.bitrade.dao.base.BaseDao;
import cn.ztuo.bitrade.entity.IeoOdf;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

public interface IeoOdfDao extends BaseDao<IeoOdf> {

    @Transactional(rollbackFor = Exception.class)
    @Modifying
    @Query(value = "UPDATE ieo_odf set remaining=remaining-:receAmount where id=:id AND " +
            "remaining>=:receAmount",nativeQuery = true)
    int subAmount(@Param("id") Long id, @Param("receAmount") BigDecimal receAmount);

}
